package com.tiger.sendmessage.wechatapi;

import jakarta.annotation.PostConstruct;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class ExecWechatService {
    private final Wechatapi wechatapi;

    public ExecWechatService(Wechatapi wechatapi) {
        this.wechatapi = wechatapi;
    }

    @PostConstruct
    public void init() {
        wechatapi.getAccessToken();
    }

    // 每小时执行更新一次token
    @Scheduled(cron = "0 0 * * * ?")
    public void executeTask() {
        wechatapi.getAccessToken();
    }
}
